package com.cskaoyan.config;

import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;


public class CustomSessionManager extends DefaultWebSessionManager {
    @Override
    protected Serializable getSessionId(ServletRequest request, ServletResponse response) {
        HttpServletRequest request1 = (HttpServletRequest) request;
        //后台的前段携带的请求头
        String sessionId = request1.getHeader("X-cskaoyan-mall-Admin-Token");
        if (sessionId != null && !sessionId.trim().equals("")) {
            return sessionId;
        }
        String header = request1.getHeader("x-litemall-admin-token");
        if (header != null && !header.trim().equals("")) {
            return header;
        }
        return super.getSessionId(request, response);
    }
}
